
package fr.unice.outils;
import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpServlet;

 
public class DataBase extends HttpServlet {
	public DataBase() {

		try {
			Class.forName("org.gjt.mm.mysql.Driver");
			Connection con;
			
			try {
				con = DriverManager.getConnection("jdbc:mysql://localhost","root","");
				//PreparedStatement create_database=con.prepareStatement("CREATE DATABASE younice;");
				//create_database.execute();
				//PreparedStatement select_db=con.prepareStatement("SELECT DATABASE younice;");
				//select_db.execute();
				
				//PreparedStatement create_table=con.prepareStatement("CREATE TABLE utilisateurs(pseudo char(25), mot_de_passe char(25), adresse_mail char(40))");
				//create_table.execute();
				//PreparedStatement insert_user=con.prepareStatement("INSERT INTO utilisateurs VALUES ('admin','adminpassword','admin@gmail.com')");
				//insert_user.execute();
				PreparedStatement get_users=con.prepareStatement("SELECT * FROM utilisateurs");
				ResultSet rs = get_users.executeQuery();
				System.err.println(rs.toString());
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
		public void init(ServletConfig config) throws ServletException
		  {
		    super.init(config);
		  }

		    @Override
		  public void doGet (HttpServletRequest request,
		                     HttpServletResponse response)
		    throws ServletException, IOException, java.net.MalformedURLException
		    {
	}
}
